const express = require('express')
const cors = require('cors')

// 创建服务器实例对象
const app = express()
// 将cors注册为全局中间件
app.use(cors())
//只解析 application/x-www-form-urlencoded 格式的表单数据
app.use(express.urlencoded({ extended:false }))

// 导入并使用用户路由模块
const userRouter = require('./router/user')
app.use('/api', userRouter)

// 导入并使用美食路由模块
const foodRouter = require('./router/food')
app.use('/api', foodRouter)

// 导入并使用民俗路由模块
const folkloricRouter = require('./router/folkloric')
app.use('/api', folkloricRouter)

// 导入并使用美景路由模块
const beautyRouter = require('./router/beauty')
app.use('/api', beautyRouter)

// 导入并使用温岭名人路由模块
const famousRouter = require('./router/famous')
app.use('/api', famousRouter)

// 启动服务器
app.listen(3000, () => {
    console.log('api serve http://localhost:3000')
})